import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { style } from '../../../theme/style';
import { GLOBAL } from '../../../config/global';
import Modal from "react-native-modal";
const scale = GLOBAL.SCALE;

export class BouncedCpt extends Component {
	constructor(props) {
		super(props);
		let { isVisible } = this.props || {};
		this.state = {
			isVisible
		}
	}

	componentWillReceiveProps (props) {
		let { isVisible } = props || {};
		this.setState({
			isVisible
		})
	}

	//关闭弹框
	// _closeFn = () => {
	// 	console.log('走自己的关闭')
	// 	this.setState({ isVisible: false })
	// }



	render () {
		let { isVisible } = this.state || {};
		let { data } = this.props || {};
		let { renderBody, closeFn } = data || {};
		return (
			<View style={{ width: '100%', height: '100%' }}>
				<Modal animationIn="slideInUp" isVisible={isVisible} style={{ position: 'relative', margin: 0, alignItems: 'flex-start', justifyContent: 'flex-start', height: '100%', zIndex: 2 }} onBackdropPress={() => { closeFn && closeFn() }}>
					<View style={styles.bouncsBox}>
						<View style={{ flex: 1 }}>
							{renderBody || null}
						</View>
					</View>
				</Modal>
			</View>
		)
	}
}

const styles = StyleSheet.create({
	bouncsBox: {
		height: '70%',
		backgroundColor: style.color.white,
		width: '100%',
		position: 'absolute',
		bottom: 0,
		borderTopLeftRadius: 16 * scale,
		borderTopRightRadius: 16 * scale,
		paddingBottom: 15 * scale
	}
})